<?php
$poll = $this->poll;
$answers = $this->answers;

$i = 1;
?>
<style type="text/css">
    .poll_input {
        width: 400px;
    }
</style>

<div class="content-box">

    <div class="content-box-header">
        <h3>Edit poll</h3>
        <ul class="content-box-tabs">
            <li><a class="default-tab" href="#tab1">Form</a></li>
        </ul>
        <div class="clear"></div>
    </div>
    <div class="content-box-content">
        <div class="tab-content default-tab" id="tab1">

            <form id="form1" method="post">
                <p>Question:</p>
                <input style="width:500px" id="question" name="question" value="<?= $poll['name'];?>"/>
                <br>
                <input type="checkbox" id="isactive"
                       name="isactive" <? if ($poll['isactive']): ?>checked="checked" <? endif;?> value="1"/> Active
                <br>

                <p>

                <p>Answers:</p>
                <? foreach ($answers as $answer): ?>
                <span><?=$i++;?>.</span>
                <input style="width:400px" id="<?=$answer['id'];?>" class="poll_input"
                       name="answer[<?=$answer['id'];?>]" value="<?= $answer['name'];?>"/><br>



                <? endforeach; ?>

                <input id="add_new_answer" type="button" value="Add answer" class="btn"/>
                <br>


                <input id="add" type="submit" value="Update" class="btn btn-primary"/>
            </form>
            <div id="question2">


            </div>
        </div>
    </div>
</div>

    <script type="text/javascript">
        $().ready(function() {
            initAddAnswerButton();
            initDelAnswerButton();
        });
    </script>

